﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CMS.BLL;

public partial class Controls_Common_ctrWelcomel : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.InitData(); 
        }
    }

    private void InitData()
    {
        string sUser = ConvertData.ConvertToString(Session[Config.SESSION_USERNAME]);
        if (sUser.Length > 0)
        {
            // Logged
            lblWelcome.Visible = true ;
            lnkLogout.Visible = true; 
            lblWelcome.Text = "Chào mừng " + " " + sUser + "!";
            lnkLogin.Visible = false;
            lnkRegister.Visible = false; 
        
        }
        else {
            lblWelcome.Visible = false ;
            lnkLogout.Visible = false; 
            lnkLogin.Visible = true;
            lnkLogin.NavigateUrl = Config.ROOT + Pages.FrontEnds.LOGIN;    
            lnkRegister.Visible = true;
            lnkRegister.NavigateUrl = Config.ROOT + Pages.FrontEnds.REGISTER;    
            
        }
    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        string sHomePage = "~/" + Pages.FrontEnds.HOME;
        Session.Clear();
        Response.Redirect(sHomePage);
    }
}
